package cn.lystudio.rohm_time_op.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.lystudio.rohm_time_op.entity.po.AppVersionPO;
import cn.lystudio.rohm_time_op.mapper.AppVersionPOMapper;
import cn.lystudio.rohm_time_op.service.AppVersionService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class AppVersionServiceImpl implements AppVersionService {
    @Resource
    private AppVersionPOMapper appVersionPOMapper;
    @Override
    public String getVersion(String appid) {
        LambdaQueryWrapper<AppVersionPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AppVersionPO::getAppid,appid)
                .last("LIMIT 1");
        AppVersionPO appVersionPO = appVersionPOMapper.selectOne(wrapper);
        if(ObjectUtil.isNotEmpty(appVersionPO)) return appVersionPO.getVersion();
        return null;
    }
}
